﻿Ext.require('Ext.*');

  Date.prototype.format = function(format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(),    //day
            "h+": this.getHours(),   //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond 
        }
        if (/(y+)/.test(format))
            format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }
    Date.prototype.DateDiff = function(strInterval, dtEnd) {
        var dtStart = this;
        switch (strInterval) {
            case 's': return parseInt((dtEnd - dtStart) / 1000);
            case 'n': return parseInt((dtEnd - dtStart) / 60000);
            case 'h': return parseInt((dtEnd - dtStart) / 3600000);
            case 'd': return parseInt((dtEnd - dtStart) / 86400000);
            case 'w': return parseInt((dtEnd - dtStart) / (86400000 * 7));
            case 'm': return (dtEnd.getMonth() + 1) + ((dtEnd.getFullYear() - dtStart.getFullYear()) * 12) - (dtStart.getMonth() + 1);
            case 'y': return dtEnd.getFullYear() - dtStart.getFullYear();
        }
    };       
    function renderOnLastUpdateDate(value) {
        var d = Ext.Date.format(new Date(parseInt(value.substring(6, value.length - 2))),'Y-m-d');
        if(d=='1-1-1')// || d=='1900/1/1')
            return "";
        return d;
        //var jsondate = value;

       // return eval("new " + jsondate.substr(1, jsondate.length - 2)).toDateString();
       // var a =new Date();
       // a.
    };
    
    function getUrlParam(param) {
        var params = Ext.urlDecode(location.search.substring(1));
        return param ? params[param] : params;
    }

/////////////////////////////////////////////////////////////////////////model
  Ext.define('workflow.models.dict', {
  extend: 'Ext.data.Model',
  alias:'widget.dict',
  fields: [
  { type:'string', name: 'id' },
  { type:'string', name: 'type' },
  { type:'string', name: 'text' },
  { type:'string', name: 'Remark' },
  { type:'string', name: 'ParentID' },
  { type:'string', name: 'IsGroup' },
  { type:'int', name: 'orderID' }
  ]
  });
  
  Ext.define('workflow.models.org', {
  extend: 'Ext.data.Model',
  alias:'widget.org',
  fields: [
  { type:'string', name: 'id' },
  { type:'string', name: 'ParentID' },
  { type:'string', name: 'orderID' },
  { type:'string', name: 'isgroup' },
  { type:'string', name: 'dwCode' },
  { type:'string', name: 'dwName' },
  { type:'int', name: 'dwType' },
  { type:'int', name: 'dwOwner' },
  { type:'int', name: 'Remark' }
  ]
  });
  
  Ext.define('mainmodel', {
  extend: 'Ext.data.Model',
  //idProperty: 'id',
  fields: [
  { name: 'id',  type:'string'},
  { name: 'gdgs', type:'string' },
  {  name: 'yhjt',type:'string' },
  {  name: 'yhly',type:'string' },
  { type:'string', name: 'yhbh' },
  { type:'string', name: 'yhdwID' },
  { type:'string', name: 'yhdw' },
  { type:'string', name: 'yhzyfl' },
  { type:'string', name: 'yhfxr' },
  { type:'string', name: 'fxrdwID' },
  { type:'string', name: 'fxrdw' },
  { type:'string', name: 'fxrq'},
  { type:'string', name: 'fxyhnr' },
  { type:'string', name: 'knhg' },
  { type:'string', name: 'ypgdj' },
  { type:'string', name: 'ypgfzr' },
  { type:'string', name: 'ypgrq1' },
  { type:'string', name: 'ypgsh2' },
  { type:'string', name: 'ypgrq2' },
  { type:'string', name: 'ypgsh3' },
  { type:'string', name: 'ypgrq3' },
  { type:'string', name: 'pgdj' },
  { type:'string', name: 'pgfzr' },
  { type:'string', name: 'pgrq1' },
  { type:'string', name: 'pgsh2' },
  { type:'string', name: 'pgrq2' },
  { type:'string', name: 'pgsh3' },
  { type:'string', name: 'pgrq3' },
  { type:'string', name: 'pgsh4' },
  { type:'string', name: 'pgrq4' },
  { type:'string', name: 'ykcs' },
  { type:'string', name: 'zgcs' },
  { type:'string', name: 'zldw' },
  { type:'string', name: 'zlr' },
  { type:'string', name: 'zlrq1' },
  { type:'string', name: 'zlrq2' },
  { type:'string', name: 'zlwcqc' },
  { type:'string', name: 'yssqdw' },
  { type:'string', name: 'yssqfzr' },
  { type:'string', name: 'yssqrq' },
  { type:'string', name: 'yszzdw' },
  { type:'string', name: 'ysyj' },
  { type:'string', name: 'ysjl' },
  { type:'string', name: 'yssfxc' },
  { type:'string', name: 'yszz' },
  { type:'string', name: 'ysrq' },
  { type:'string', name: 'lcflag' },
  { type:'string', name: 'tjflag' },
  { type:'string', name: 'bhflag' },
  { type:'string', name: 'gsbm' },
  { type:'string', name: 'tjr' },
  { type:'string', name: 'dqyh' },
  { type:'string', name: 'dqyhsj' },
  { type:'string', name: 'backflag' },
  { type:'string', name: 'backer' },
  { type:'string', name: 'backdate' },
  { type:'string', name: 'lcstatus' },
  { type:'string', name: 'zlflag' },
  { type:'string', name: 'zlstatus' },
  { type:'string', name: 'tjrq' },
  { type:'string', name: 'lcrecord' },
  { type:'string', name: 'fxrgh' },
  { type:'string', name: 'sfzykz' }
  ]
  });
  
  Ext.define('workflow.models.treemodel', {
        extend: 'Ext.data.Model',
        fields: [{
        name: 'text',
        type:'string'
        }, {name:'id',type:'string'},{name: 'lead',type:'bool'}]
                                    
});

////////////////////////////////////////////////////////////////store
var taskStore=Ext.create('Ext.data.Store',{
                    model:'mainmodel',
                    autoLoad: true,
                    autoSync: true,
                    pageSize:15,
                    //queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        api: {
                        read: 'workflow_tasklist_ajax.aspx?action=read',
                        create:'workflow_tasklist_ajax.aspx?action=create'
                        },
                        reader: {
                            type: 'json',
                            successProperty: 'success',
                            root: 'data',
                            totalProperty:'total',
                            messageProperty: 'message'
                        },
                        extraParams: {
                            wfid: getUrlParam('wfid')
                        },
                        listeners: {
                            exception: function(proxy, response, operation) {
                            var msg=""+operation.getError();
                            if(msg && msg.length>0)
                                Ext.MessageBox.show({
                                    title: '提示信息',
                                    msg: msg,
                                    //icon: Ext.MessageBox.ERROR,
                                    buttons: Ext.Msg.OK
                                });
                            }
                        },
                        callback:function(){
                        
                        //alert(taskStore.items.count);
                            //for(var i=0;i<taskStore.items.count
                           // changeDate(this.items[0].data);
                        }
                    }
                });

var initStore=Ext.create('Ext.data.Store',{
                    model:'mainmodel',
                    autoLoad: true,
                    //autoSync: true,
                    //pageSize:5,
                    queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        //api: {
                        url: 'workflow_init_ajax.aspx?action=read',
                        //},
                        reader: {
                            type: 'json',
                            successProperty: 'success',
                            root: 'data',
                            totalProperty:'total',
                            messageProperty: 'message'
                        },
                        extraParams: {
                            wfid: 100
                        },
                        listeners: {
                            exception: function(proxy, response, operation) {
                            var msg=""+operation.getError();
                            if(msg && msg.length>0)
                                Ext.MessageBox.show({
                                    title: '提示信息',
                                    msg: msg,
                                    //icon: Ext.MessageBox.ERROR,
                                    buttons: Ext.Msg.OK
                                });
                            }
                        }
                    }
                });
 //initStore.load();

var yhlyStore=Ext.create('Ext.data.Store',{
                    model:'workflow.models.dict',
                    autoLoad: true,
                    //autoSync: true,
                    queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        url: 'workflow_dict_ajax.aspx?action=read&sType='+encodeURIComponent('隐患来源'),
                        reader: {
                            type: 'json',
                            root: 'data'
                        }
                        }
                    
                });
var yhzyflStore=Ext.create('Ext.data.Store',{
                    model:'workflow.models.dict',
                    autoLoad: true,
                    //autoSync: true,
                    queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        url: 'workflow_dict_ajax.aspx?action=read&sType='+encodeURIComponent('专业分类'),
                        reader: {
                            type: 'json',
                            root: 'data'
                        }
                        }
                    
                });
                
var knhgStore=Ext.create('Ext.data.Store',{
                    model:'workflow.models.dict',
                    autoLoad: true,
                    //autoSync: true,
                    queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        url: 'workflow_dict_ajax.aspx?action=read&sType='+encodeURIComponent('可能导致后果'),
                        reader: {
                            type: 'json',
                            root: 'data'
                        }
                        }
                    
                }); 

var ypgdjStore = Ext.create('Ext.data.Store',{
                    model:'workflow.models.dict',
                    autoLoad: true,
                    //autoSync: true,
                    queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        url: 'workflow_dict_ajax.aspx?action=read&sType='+encodeURIComponent('预评估等级'),
                        reader: {
                            type: 'json',
                            root: 'data'
                        }
                        }
                });  
                
var gsbmStore = Ext.create('Ext.data.Store',{
                    model:'workflow.models.org',
                    autoLoad: true,
                    autoSync: true,
                    queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        url: 'workflow_org_ajax.aspx?action=read&type=gsbm',
                        reader: {
                            type: 'json',
                            root: 'data'
                        }
                        }
                });        

var orgStore=Ext.create('Ext.data.Store',{
                    model:'workflow.models.org',
                    autoLoad: true,
                    //autoSync: true,
                    queryMode: 'local',
                    proxy: {
                        type: 'ajax',
                        url: 'workflow_org_ajax.aspx?action=read&type=org',
                        reader: {
                            type: 'json',
                            root: 'data'
                        },
                        extraParams: {
                            wfid: getUrlParam('wfid')
                        }
                        }
                    
                });

var yssfxcStore=Ext.create('Ext.data.Store',{
                    fields:[{name:'text',type:'string'}],
                    queryMode: 'local',
                    data:[{'text':'是'},{'text':'否'}]
                    
                });

///////////////////////////////////////////////////////////////////view
/*Ext.define('workflow.views.wftree', {
    extend: 'Ext.tree.Panel',
    alias:'widget.wftree',
    collapseDirection: 'left',
    collapsed: false,
    collapsible: true,
    title: '流程管理',
    rootVisible: true,
    root:{id:"000",text:'流程',expanded:true},
    store: Ext.create('Ext.data.TreeStore',{
	    model:'workflow.models.treemodel',
	    autoLoad: true,
        //autoSync: true,
        queryMode: 'local',
        proxy: {
            type: 'ajax',
            api: {
            read: 'workflow_tree_ajax.aspx?action=read'
            },
            reader: {
                type: 'json',
                successProperty: 'success',
                root: 'data',
                messageProperty: 'message'
            },
            listeners: {
                exception: function(proxy, response, operation) {
                    Ext.MessageBox.show({
                        title: 'REMOTE EXCEPTION',
                        msg: operation.getError(),
                        icon: Ext.MessageBox.ERROR,
                        buttons: Ext.Msg.OK
                    });
                }
            }
        }
     
    }),//treestore,

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            viewConfig: {

            }
        });

        me.callParent(arguments);
    },
    listeners : {  
        afterrender: function (tree) {
              tree.getSelectionModel()
         },
        itemclick : function(view,re){  
            treeClick(re.data);
            //Ext.getCmp('com_source_1').setDisabled(false);
           
        },
        load: function(obj){
            this.getSelectionModel().select(1);
            treeClick(Ext.getCmp('wftree1').getRootNode().firstChild.data);
           //this.fireEvent('itemclick',Ext.getCmp('wftree1').getRootNode().firstChild);
        }
    }  
});
*//*
var treeClick=function(data)
{
window.clearInterval(timeId);
g_id="";
    if(data.id=='100' || data.id=='101')
            {
                
                 Ext.getCmp('tasklist1').setTitle('任务列表--'+data.text);
                Ext.getCmp('mainform1').setVisible(false);
                Ext.getCmp('tasklist1').setVisible(true);
                Ext.getCmp('add').setVisible(true);
                Ext.getCmp('edit').setVisible(true);
                Ext.getCmp('exec').setVisible(false);
                Ext.getCmp('back').setVisible(false);
                Ext.getCmp('tasklist1').store.load({
                 params: {
                              wfid: data.id
                         }
            }); 
                
            }
            else{
                Ext.getCmp('tasklist1').setTitle('任务列表--'+data.text);
                Ext.getCmp('mainform1').setVisible(false);
                Ext.getCmp('tasklist1').setVisible(true);
                Ext.getCmp('add').setVisible(false);
                Ext.getCmp('edit').setVisible(false);
                Ext.getCmp('exec').setVisible(true);
                Ext.getCmp('back').setVisible(true);
            Ext.getCmp('tasklist1').store.load({
                 params: {
                              wfid: data.id
                         }
            }); 
             }
             if(data.id=='200')
             {
                Ext.getCmp('back').setVisible(false);
             }
}; */

var initCom=function(id,text)
{
    window.clearInterval(timeId);
g_id="";
    
     Ext.getCmp('mainform1').items.each(function(item,index,length){
     if (item.initialConfig.hasOwnProperty("id")) {
     
         if(item.initialConfig.id.indexOf('$'+id)<=0)    
        {
            item.collapse();
        }
     }
    
    });
    if(id=='100' || id=='101')
            {
                
                 Ext.getCmp('tasklist1').setTitle('任务列表--'+text);
                Ext.getCmp('mainform1').setVisible(false);
                Ext.getCmp('tasklist1').setVisible(true);
                Ext.getCmp('add').setVisible(true);
                Ext.getCmp('edit').setVisible(true);
                Ext.getCmp('exec').setVisible(false);
                Ext.getCmp('back').setVisible(false);
                Ext.getCmp('change').setVisible(false);
                Ext.getCmp('mainexec').setText('上报');
                Ext.getCmp('tasklist1').store.load({
                 params: {
                              wfid: id
                         }
            }); 
                
            }
            else{
                Ext.getCmp('tasklist1').setTitle('任务列表--'+text);
                Ext.getCmp('mainform1').setVisible(false);
                Ext.getCmp('tasklist1').setVisible(true);
                Ext.getCmp('add').setVisible(false);
                Ext.getCmp('edit').setVisible(false);
                Ext.getCmp('exec').setVisible(true);
                Ext.getCmp('change').setVisible(false);
               // Ext.getCmp('back').setDisabled(t);
            Ext.getCmp('tasklist1').store.load({
                 params: {
                              wfid: id
                         }
            }); 
             }
             if(id=='200')
             {
                Ext.getCmp('back').setVisible(false);
                Ext.getCmp('mainexec').setText('验收申请');
                
             }
             if(id=='201')
             {
                Ext.getCmp('back').setVisible(false);
                Ext.getCmp('mainexec').setText('验收');
             }
             if(id=='105' || id=='106'  || id=='107' || id=='108')
                 Ext.getCmp('change').setVisible(true);
}

var changeDate=function(objList)
{
    for(var obj in objList)
    {
       if(objList[obj].indexOf('Date(')>0)
            objList[obj]=renderOnLastUpdateDate(objList[obj]);
    }
}

var recursionSet=function(parent,step)
{
    parent.items.each(function(item,index,length){
    try{
        if(item.items && item.items.getCount()>0)
        {
            recursionSet(item,step);
        }
        else
        {
            setCtrl(item,step);
        }
       }
       catch(e)
       {
            setCtrl(item,step);  
       }
       
    });
};

var setCtrl=function(item,step)
{
    if(item.initialConfig.id.indexOf('@'+step)>0)    
    {
        item.setDisabled(false);
        item.allowBlank=false;
    }
    else if(item.initialConfig.id.indexOf('_'+step)>0)    
    {
        item.setDisabled(false);
        item.allowBlank=true;
    }
    else
    {
        item.setDisabled(true);
        item.allowBlank=true;
    }
};

var restoreCtrl=function(item,step)
{
    
}

var canSubmit=function(parent,step)
{
    var str="";
    parent.items.each(function(item,index,length){
    try{
        if(item.items && item.items.getCount()>0)
        {
            str+=canSubmit(item,step);
        }
        else
        {
            if(!checkItem(item,step))
                str+=item.initialConfig.fieldLabel+","
        }
       }
       catch(e)
       {
            if(!checkItem(item,step))
                str+=item.initialConfig.fieldLabel+","
       }
    });
    return str;

}
/*    Ext.MessageBox.show({
                        title: '提示',
                        msg: str+'字段不能为空',
                        buttons: Ext.Msg.OK
                    });*/
var checkItem=function(item,step)
{
    if(item.initialConfig.id.indexOf('@'+step)>0)    
    {
        if(item.lastValue=="" || item.lastValue==null)
            return false;
    }
    return true;
}


Ext.define('workflow.views.mainform', {
    extend: 'Ext.form.Panel',
    alias: 'widget.mainform',
    border: '',
    //height: 1240,
    autoHeight: true,
    id: 'form_total',
    autoScroll: true,
    title: '隐患排查治理档案表',

    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            dockedItems: [{
                xtype: 'toolbar',
                items: [{
                    iconCls: 'icon-exec',
                    text: '上报',
                    itemId: 'mainexec',
                    id:'mainexec',
                    scope: this,
                    handler: this.onExecClick
                },
                {
                    iconCls: 'icon-reset',
                    text: '退回',
                    itemId: 'back',
                    id:'back',
                    scope: this,
                    handler: this.onBackClick
                },
                {
                    iconCls: 'icon-back',
                    text: '返回',
                    itemId: 'return',
                    id:'return',
                    scope: this,
                    handler: this.onReturnClick
                }]
                }],
            items: [
                {
                    xtype: 'panel',
                    height: 265,
                    id: 'discover$100$101$102$103$104$105$106$107$108',
                    layout: {
                        type: 'anchor'
                    },
                    collapsible: true,
                    title: '发现',
                    items: [
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'yhjt@100@101@102@103@104@105@106@107@108',
                                    width: 459,
                                    name: 'yhjt',
                                    fieldLabel: '　事故隐患简题',
                                    labelWidth: 90,
                                    emptyText: '',
                                    columnWidth: 0.8
                                },
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'yhly@100@101@102@103@104@105@106@107@108',
                                    name: 'yhly',
                                    fieldLabel: '　隐患来源',
                                    labelWidth: 65,
                                    editable: false,
                                    columnWidth: 0.2,
                                    displayField:'text',
                                    valueField:'text',
                                    store:yhlyStore
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'yhbh@100@101',
                                    name: 'yhbh',
                                    fieldLabel: '　隐患编号',
                                    labelWidth: 90,
                                    blankText: '',
                                    columnWidth: 0.33
                                },
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'yhdw@100@101',
                                    name: 'yhdw',
                                    fieldLabel: '　隐患所在单位',
                                    labelWidth: 90,
                                    editable: false,
                                    columnWidth: 0.34,
                                    displayField:'dwName',
                                    valueField:'dwName',
                                    store:orgStore
                                },
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'yhzyfl@100@101@102@103@104',
                                    name: 'yhzyfl',
                                    fieldLabel: '　专业分类',
                                    labelWidth: 65,
                                    editable: false,
                                    columnWidth: 0.33,
                                    displayField:'text',
                                    valueField:'text',
                                    store:yhzyflStore
                                    
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'yhfxr@100@101',
                                    itemId: '',
                                    name: 'yhfxr',
                                    fieldLabel: '　隐患发现人',
                                    labelStyle: '',
                                    labelWidth: 90,
                                    columnWidth: 0.21
                                },
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'fxrgh@100@101',
                                    itemId: '',
                                    name: 'fxrgh',
                                    fieldLabel: '　发现人工号',
                                    labelStyle: '',
                                    labelWidth: 90,
                                    columnWidth: 0.21
                                },
                                {
                                    xtype: 'checkboxfield',
                                    disabled: true,
                                    id: 'sfzykz_100_101',
                                    fieldLabel: '　是否主业开支',
                                    name:'sfzykz',
                                    labelWidth: 95,
                                    boxLabel: '',
                                    columnWidth: 0.14
                                },
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'fxrdw@100@101',
                                    name: 'fxrdw',
                                    fieldLabel: '　发现人单位',
                                    labelWidth: 90,
                                    editable: false,
                                    columnWidth: 0.23,
                                    displayField:'dwName',
                                    valueField:'dwName',
                                    store:orgStore
                                },
                                {
                                    xtype: 'datefield',
                                    disabled: true,
                                    id: 'fxrq@100@101',
                                    invalidText: '日期格式不正确（年-月-日）',
                                    name: 'fxrq',
                                    fieldLabel: '　发现日期',
                                    labelWidth: 65,
                                   // value:new Date('2011-1-1'),
                                    editable: false,
                                    format: 'Y-m-d',
                                    maxText: '日期必须小于{maxValue}',
                                    minText: '日期必须大于{minValue}',
                                    columnWidth: 0.21,
                                    listener:{
                                        change:renderOnLastUpdateDate
                                    },
                                    //renderer:renderOnLastUpdateDate
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 121,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            anchor: '100%',
                            items: [
                                {
                                    xtype: 'textareafield',
                                    disabled: true,
                                    height: 104,
                                    id:  'fxyhnr@100@101@102@103@104@105@106@107@108',//'fxyhnr@100@101_102_103_104_105_106_107_108',
                                    name: 'fxyhnr',
                                    fieldLabel: '　事故隐患内容',
                                    labelWidth: 90,
                                    columnWidth: 1
                                }
                            ]
                        }
                    ]
                },
                {
                    xtype: 'panel',
                    height: 179,
                    id: 'toassess$102$103$104$105$106$107$108',
                    layout: {
                        type: 'anchor'
                    },
                    collapsible: true,
                    title: '预评估',
                    items: [
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'knhg@102@103@104@105@106@107@108',
                                    name: 'knhg',
                                    fieldLabel: '　可能导致后果',
                                    labelWidth: 90,
                                    blankText: '',
                                    emptyText: '',
                                    editable:true,
                                    columnWidth: 0.3,
                                    displayField:'text',
                                    valueField:'text',
                                    store:knhgStore
                                },
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'gsbm@102@103@104',
                                    name: 'gsbm',
                                    editable: true,
                                    fieldLabel: '　归属职能部门',
                                    labelWidth: 125,
                                    columnWidth: 0.7,
                                    displayField:'dwName',
                                    valueField:'dwName',
                                    store: gsbmStore
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 123,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'container',
                                    height: 120,
                                    padding: '43 0 0 5',
                                    layout: {
                                        type: 'column'
                                    },
                                    columnWidth: 0.3,
                                    items: [
                                        {
                                            xtype: 'combobox',
                                            disabled: true,
                                            id: 'ypgdj@102_103_104',
                                            name: 'ypgdj',
                                            fieldLabel: '　预评估等级',
                                            labelWidth: 90,
                                            editable: false,
                                            columnWidth: 1,
                                            displayField:'text',
                                            valueField:'text',
                                            store:ypgdjStore
                                        }
                                    ]
                                },
                                {
                                    xtype: 'container',
                                    height: 120,
                                    width: 500,
                                    layout: {
                                        type: 'anchor'
                                    },
                                    columnWidth: 0.7,
                                    items: [
                                        {
                                            xtype: 'container',
                                            height: 40,
                                            autoScroll:false,
                                            padding: 5,
                                            layout: {
                                                type: 'column'
                                            },
                                            items: [
                                                {
                                                    xtype: 'textfield',
                                                    disabled: true,
                                                    id: 'ypgfzr@102',
                                                    name: 'ypgfzr',
                                                    fieldLabel: '预评估负责人签名',
                                                    labelWidth: 125,
                                                    columnWidth: 0.5
                                                },
                                                {
                                                    xtype: 'datefield',
                                                    disabled: true,
                                                    id: 'ypgrq1@102',
                                                    name: 'ypgrq1',
                                                    fieldLabel: '　预评估负责人签名日期',
                                                    labelWidth: 160,
                                                    format: 'Y-m-d',
                                                    editable: false,
                                                    columnWidth: 0.5
                                                }
                                            ]
                                        },
                                        {
                                            xtype: 'container',
                                            height: 40,
                                            padding: 5,
                                            layout: {
                                                type: 'column'
                                            },
                                            items: [
                                                {
                                                    xtype: 'textfield',
                                                    disabled: true,
                                                    id: 'ypgsh2@103',
                                                    name: 'ypgsh2',
                                                    fieldLabel: '规范性审核负责人签名',
                                                    labelWidth: 125,
                                                    columnWidth: 0.5
                                                },
                                                {
                                                    xtype: 'datefield',
                                                    disabled: true,
                                                    id: 'ypgrq2@103',
                                                    name: 'ypgrq2',
                                                    fieldLabel: '　规范性审核负责人签名日期',
                                                    labelWidth: 160,
                                                    editable: false,
                                                    format: 'Y-m-d',
                                                    columnWidth: 0.5
                                                }
                                            ]
                                        },
                                        {
                                            xtype: 'container',
                                            height: 40,
                                            padding: 5,
                                            layout: {
                                                type: 'column'
                                            },
                                            items: [
                                                {
                                                    xtype: 'textfield',
                                                    disabled: true,
                                                    id: 'ypgsh3@104',
                                                    name: 'ypgsh3',
                                                    fieldLabel: '工区领导审核签名',
                                                    labelWidth: 125,
                                                    columnWidth: 0.5
                                                },
                                                {
                                                    xtype: 'datefield',
                                                    disabled: true,
                                                    id: 'ypgrq3@104',
                                                    name: 'ypgrq3',
                                                    fieldLabel: '　工区领导审核签名日期',
                                                    labelWidth: 160,
                                                    format: 'Y-m-d',
                                                    editable: false,
                                                    columnWidth: 0.5
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    xtype: 'panel',
                    height: 180,
                    id: 'assessing$105$106$107$108',
                    layout: {
                        type: 'column'
                    },
                    collapsible: true,
                    title: '评估',
                    items: [
                        {
                            xtype: 'container',
                            height: 111,
                            padding: '43 0 0 5',
                            width: 250,
                            layout: {
                                type: 'column'
                            },
                            columnWidth: 0.3,
                            items: [
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'pgdj@105_106_107_108',
                                    name: 'pgdj',
                                    fieldLabel: '　评估等级',
                                    labelWidth: 70,
                                    editable: false,
                                    columnWidth: 1,
                                    displayField:'text',
                                    valueField:'text',
                                    store:ypgdjStore
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 148,
                            width: 500,
                            layout: {
                                type: 'anchor'
                            },
                            columnWidth: 0.7,
                            items: [
                                {
                                    xtype: 'container',
                                    height: 37,
                                    padding: 5,
                                    layout: {
                                        type: 'column'
                                    },
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            disabled: true,
                                            id: 'pgfzr@105',
                                            name: 'pgfzr',
                                            fieldLabel: '评估负责人签名',
                                            labelWidth: 125,
                                            columnWidth: 0.5
                                        },
                                        {
                                            xtype: 'datefield',
                                            disabled: true,
                                            id: 'pgrq1@105',
                                            name: 'pgrq1',
                                            fieldLabel: '　评估负责人签名日期',
                                            labelWidth: 165,
                                            editable: false,
                                            format: 'Y-m-d',
                                            columnWidth: 0.5
                                        }
                                    ]
                                },
                                {
                                    xtype: 'container',
                                    height: 37,
                                    padding: 5,
                                    layout: {
                                        type: 'column'
                                    },
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            disabled: true,
                                            id: 'pgsh2@106',
                                            name: 'pgsh2',
                                            fieldLabel: '部门负责人审核签名',
                                            labelWidth: 125,
                                            columnWidth: 0.5
                                        },
                                        {
                                            xtype: 'datefield',
                                            disabled: true,
                                            id: 'pgrq2@106',
                                            name: 'pgrq2',
                                            format: 'Y-m-d',
                                            fieldLabel: '　部门负责人审核签名日期',
                                            labelWidth: 165,
                                            editable: false,
                                            columnWidth: 0.5
                                        }
                                    ]
                                },
                                {
                                    xtype: 'container',
                                    height: 37,
                                    padding: 5,
                                    layout: {
                                        type: 'column'
                                    },
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            disabled: true,
                                            id: 'pgsh3@107',
                                            name: 'pgsh3',
                                            fieldLabel: '规范性审核负责人签名',
                                            labelWidth: 125,
                                            columnWidth: 0.5
                                        },
                                        {
                                            xtype: 'datefield',
                                            disabled: true,
                                            id: 'pgrq3@107',
                                            name: 'pgrq3',
                                            fieldLabel: '　规范性审核负责人签名日期',
                                            labelWidth: 165,
                                            format: 'Y-m-d',
                                            editable: false,
                                            columnWidth: 0.5
                                        }
                                    ]
                                },
                                {
                                    xtype: 'container',
                                    height: 37,
                                    padding: 5,
                                    layout: {
                                        type: 'column'
                                    },
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            disabled: true,
                                            id: 'pgsh4@108',
                                            name: 'pgsh4',
                                            fieldLabel: '地市领导审核签名',
                                            labelWidth: 125,
                                            columnWidth: 0.5
                                        },
                                        {
                                            xtype: 'datefield',
                                            disabled: true,
                                            id: 'pgrq4@108',
                                            name: 'pgrq4',
                                            fieldLabel: '　地市领导审核签名日期',
                                            labelWidth: 165,
                                            format: 'Y-m-d',
                                            columnWidth: 0.5
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    xtype: 'panel',
                    height: 163,
                    id: 'method$102$103$104$105$106$107$108',
                    layout: {
                        type: 'anchor'
                    },
                    collapsible: true,
                    title: '措施',
                    items: [
                        {
                            xtype: 'textareafield',
                            disabled: true,
                            height: 60,
                            id: 'ykcs@102_103_104_105_106_107_108',
                            margin: 5,
                            name: 'ykcs',
                            fieldLabel: '　预控措施',
                            labelWidth: 70,
                            anchor: '100%'
                        },
                        {
                            xtype: 'textareafield',
                            disabled: true,
                            height: 60,
                            id: 'zgcs_102_103_104@105_106_107_108',
                            margin: 5,
                            name: 'zgcs',
                            fieldLabel: '　整改措施',
                            labelWidth: 70,
                            anchor: '100%'
                        }
                    ]
                },
                {
                    xtype: 'panel',
                    height: 160,
                    id: 'govern$102$103$104$105$106$107$108$200$201',
                    layout: {
                        type: 'anchor'
                    },
                    collapsible: true,
                    title: '治理',
                    items: [
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'zldw_102_103_104@105_106_107_108_200',
                                    name: 'zldw',
                                    fieldLabel: '　治理责任单位',
                                    labelWidth: 90,
                                    editable: false,
                                    columnWidth: 0.6,
                                    displayField:'dwName',
                                    valueField:'dwName',
                                    store:orgStore
                                },
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'zlr_102_103_104@105_106_107_108_200',
                                    name: 'zlr',
                                    fieldLabel: '　治理责任人',
                                    labelWidth: 80,
                                    columnWidth: 0.4
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'datefield',
                                    disabled: true,
                                    id: 'zlrq1_102_103_104@105_106_107_108_200_201',
                                    name: 'zlrq1',
                                    fieldLabel: '　治理期限，自',
                                    labelWidth: 90,
                                    editable: false,
                                    format: 'Y-m-d',
                                    columnWidth: 0.6
                                },
                                {
                                    xtype: 'datefield',
                                    disabled: true,
                                    id: 'zlrq2_102_103_104@105_106_107_108_200_201',
                                    name: 'zlrq2',
                                    fieldLabel: '　至',
                                    labelWidth: 40,
                                    editable: false,
                                    format: 'Y-m-d',
                                    columnWidth: 0.4
                                }
                            ]
                        },
                        {
                            xtype: 'textareafield',
                            disabled: true,
                            height: 50,
                            id: 'zlwcqc_107@200_201',
                            name: 'zlwcqc',
                            fieldLabel: '　 治理完成情况',
                            labelWidth: 95,
                            anchor: '100%'
                        }
                    ]
                },
                {
                    xtype: 'panel',
                    height: 240,
                    id: 'check$107$200$201',
                    layout: {
                        type: 'anchor'
                    },
                    collapsible: true,
                    title: '验收',
                    items: [
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'yssqdw_107@200@201',
                                    name: 'yssqdw',
                                    fieldLabel: '　验收申请单位',
                                    labelWidth: 90,
                                    editable: false,
                                    columnWidth: 0.4,
                                    displayField:'dwName',
                                    valueField:'dwName',
                                    store:orgStore
                                },
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'yssqfzr_107@200@201',
                                    name: 'yssqfzr',
                                    fieldLabel: '　负责人',
                                    labelWidth: 60,
                                    columnWidth: 0.3
                                },
                                {
                                    xtype: 'datefield',
                                    disabled: true,
                                    id: 'yssqrq_107@200@201',
                                    name: 'yssqrq',
                                    fieldLabel: '　日期',
                                    labelWidth: 50,
                                    editable: false,
                                    format: 'Y-m-d',
                                    columnWidth: 0.3
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'yszzdw_107@200@201',
                                    name: 'yszzdw',
                                    fieldLabel: '　验收组织单位',
                                    labelWidth: 90,
                                    editable: false,
                                    columnWidth: 1,
                                    displayField:'dwName',
                                    valueField:'dwName',
                                    store:gsbmStore
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 65,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'textareafield',
                                    disabled: true,
                                    height: 50,
                                    id: 'ysyj_107@201',
                                    width: 658,
                                    name: 'ysyj',
                                    fieldLabel: '　验收意见',
                                    labelWidth: 90,
                                    columnWidth: 1
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'ysjl_107@201',
                                    name: 'ysjl',
                                    fieldLabel: '　结　　论',
                                    labelWidth: 90,
                                    columnWidth: 0.7
                                },
                                {
                                    xtype: 'combobox',
                                    disabled: true,
                                    id: 'yssfxc_107@201',
                                    name: 'yssfxc',
                                    fieldLabel: '　是否消除',
                                    labelWidth: 70,
                                    editable: false,
                                    columnWidth: 0.3,
                                    displayField:'text',
                                    valueField:'text',
                                    store:yssfxcStore
                                }
                            ]
                        },
                        {
                            xtype: 'container',
                            height: 37,
                            padding: 5,
                            layout: {
                                type: 'column'
                            },
                            items: [
                                {
                                    xtype: 'textfield',
                                    disabled: true,
                                    id: 'yszz_107@201',
                                    name: 'yszz',
                                    fieldLabel: '　验收组长',
                                    labelWidth: 90,
                                    columnWidth: 0.7
                                },
                                {
                                    xtype: 'datefield',
                                    disabled: true,
                                    id: 'ysrq_107@201',
                                    name: 'ysrq',
                                    fieldLabel: '　验收日期',
                                    labelWidth: 70,
                                    editable: false,
                                    format: 'Y-m-d',
                                    columnWidth: 0.3
                                }
                            ]
                        }
                    ]
                },
                {
                 xtype: 'images-view',
                 collapsible: false
                }
            ]
        });

        me.callParent(arguments);
    },
   
    setActiveRecord: function(record) {
                    this.activeRecord = record;
                    if (record) {
                        this.getForm().loadRecord(record);
                         Ext.getCmp('images-view').setActiveRecord(record);
                    } else {
                        this.getForm().reset();
                    }
                }
});



Ext.define('workflow.views.tasklist', {
                extend: 'Ext.grid.Panel',
                alias: 'widget.tasklist',

                requires: [
        'Ext.grid.plugin.CellEditing',
        'Ext.form.field.Text',
        'Ext.toolbar.TextItem'
    ],
                title:'任务列表',
                frame:true,
                width:1300,
                viewConfig: {
                    stripeRows: false,            
                    getRowClass: function(record, index, rowParams, store) {
                        if (record.data.yssfxc == '否' || record.data.yssfxc == '') {
                            var date1 = new Date();
                            date1 = new Date(date1.getFullYear(),date1.getMonth(), date1.getDate());
                            var zlrq = record.data.zlrq2;
                            var date2 = new Date(parseInt(zlrq.substring(6, zlrq.length - 2)))
                            var day = date1.DateDiff('d', date2);
                            //console.log(day);
                            if (day < -10000 || day > 7) return '';
                            if (day < 0)
                                return 'x-grid-record-red';
                            else
                                return 'x-grid-record-yellow';
                        }
                        else
                            return '';
                    }
                },
                initComponent: function() {

                   // this.editing = Ext.create('Ext.grid.plugin.CellEditing');

                    Ext.apply(this, {
                        iconCls: 'icon-grid',
                        //getRowClass:getRowColor,
                        //frame: true,
                      //  plugins: [this.editing],
                        dockedItems: [{
                            xtype: 'toolbar',
                            items: [{
                                iconCls: 'icon-add',
                                text: '新建',
                                itemId: 'add',
                                id:'add',
                                scope: this,
                                handler: this.onAddClick
                            },{
                                iconCls: 'icon-grid',
                                text: '编辑',
                                disabled: true,
                                itemId: 'edit',
                                id:'edit',
                                scope: this,
                                handler: this.onEditClick
                            },{
                                iconCls: 'icon-user',
                                text: '打开',
                                disabled: true,
                                itemId: 'exec',
                                id:'exec',
                                scope: this,
                                handler: this.onExecClick
                            },{
                                iconCls: 'icon-user',
                                text: '归属部门修改',
                                disabled: true,
                                itemId: 'change',
                                id:'change',
                                scope: this,
                                handler: this.onChangeClick
                            },{
                                iconCls: 'icon-error',
                                text: '隐患记录颜色说明',
                                itemId: 'state',
                                id:'state',
                                scope: this,
                                handler: this.onStateClick
                            }]
                            },
                            {
                                xtype: 'pagingtoolbar',
                                store: taskStore,  // same store GridPanel is using
                                dock: 'bottom', //分页 位置
                                emptyMsg: '没有数据',
                                displayInfo: true,
                                displayMsg: '当前显示{0}-{1}条记录 / 共{2}条记录 ',
                                beforePageText: '第',
                                afterPageText: '页/共{0}页'
                            }],
                columns: [{
                    text: 'id',
                    width: 40,
                    sortable: true,
                    hidden:true,
                    dataIndex: 'id'
                }, {
                    header: '隐患简题',
                    width: 100,
                    sortable: true,
                    dataIndex: 'yhjt',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '隐患来源',
                    width: 100,
                    sortable: true,
                    dataIndex: 'yhly',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '隐患编号',
                    //flex: 1,
                    width: 100,
                    sortable: true,
                    dataIndex: 'yhbh',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '隐患单位',
                    //flex: 1,
                    width: 100,
                    sortable: true,
                    dataIndex: 'yhdw',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '专业分类',
                    //flex: 1,
                    width: 100,
                    sortable: true,
                    dataIndex: 'yhzyfl',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '发现人',
                    //flex: 1,
                    width: 100,
                    sortable: true,
                    dataIndex: 'yhfxr',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '发现日期',
                    //flex: 1,
                    width: 100,
                    sortable: true,
                    dataIndex: 'fxrq',
                    format:'Y-m-d',
                    renderer:  renderOnLastUpdateDate,
                    field: {
                        type: 'datefield'
                    }
                },  {
                    header: '流程状态',
                    //flex: 1,
                    width: 100,
                    sortable: true,
                    dataIndex: 'lcstatus',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '治理状态',
                    //flex: 1,
                    width: 100,
                    sortable: true,
                    dataIndex: 'zlstatus',
                    field: {
                        type: 'textfield'
                    }
                }, {
                    header: '提交时间',
                    //flex: 1,
                    sortable: true,
                    width: 100,
                    dataIndex: 'tjrq',
                    renderer:  renderOnLastUpdateDate,
                    field: {
                        type: 'textfield'
                    }
                }]
                });
                this.callParent();
                this.getSelectionModel().on('selectionchange', this.onSelectChange, this);
            },
            onSelectChange: function(selModel, selections) {
                this.down('#exec').setDisabled(selections.length === 0);
                this.down('#edit').setDisabled(selections.length === 0);
                this.down('#change').setDisabled(selections.length === 0);
            }
        });
     
                                            
var updateRecord=function(values,record)
{
    for(var tmp in values)
    {
        record[tmp]=values[tmp];
    }
};
var timeId;
var g_id;
var updateUsing=function()
{  
    if(id!="" && id!=null && id!="undefined")
     Ext.Ajax.request( {
            url :'workflow_check_ajax.aspx?type=update&id='+g_id,
            method :'post',
           
            success : function(d) {
            },
            failure : function(d) {
            }
        });
}
 Ext.Loader.setConfig({ enabled: true });
Ext.Loader.setPath('Ext.ux.DataView', '../Ext.ux.UploadDialog/UploadDialog/');
Ext.require(['Ext.data.*', 'Ext.grid.*', 'Ext.util.*',
    'Ext.view.View',
    'Ext.ux.DataView.DragSelector',
       'Ext.ux.DataView.LabelEditor']);
Ext.onReady(function(){
Ext.tip.QuickTipManager.init();
  var fl_id=getUrlParam('wfid');
  var fl_text=getUrlParam('text');
   Ext.create('Ext.Viewport', 
   
   {
        layout: {
            type: 'border',
            padding: 5
        },
        defaults: {
            split: true
        },
        height:500,
        items: [/*{
            xtype:'wftree',
            id:'wftree1',
            region:'west',
            width:200
            //padding:'0 5 0 0'
            
        },*/{
        region:'center',
        layout:'border',
        border:false,
        items:[{
            xtype:'mainform',
            title: '隐患记录',
            id:'mainform1',
            itemId:'mainform1',
            region:'center',
            collapsible: true,
            //width:750,
            onExecClick: function() {
                    //alert(this.activeRecord.data.lcflag);//this.data.lcflag);
                    var rst=canSubmit(Ext.getCmp('mainform1'),fl_id);
                    rst=rst.substring(0,rst.length-1);
                    if(rst!="")
                    {
                        Ext.MessageBox.show({
                            title: '提示',
                            msg: rst+'字段不能为空',
                            buttons: Ext.Msg.OK
                        });
                    }
                    else
                    {
                        this.form._record.data.bhflag= fl_id;
                        updateRecord(this.form.getValues(),this.form._record.data);
                        var insertmodel=new mainmodel(this.form._record.data);
                        insertmodel.phantom=true;
                        //initCom(fl_id,fl_text);
                                                            Ext.getCmp('mainform1').setVisible(false);
                                                            Ext.getCmp('tasklist1').setVisible(true);
                       
                        taskStore.insert(0,insertmodel);
                         taskStore.load({
                                 params: {
                                              wfid: fl_id
                                         }
                            }); 
                         window.clearInterval(timeId);
                         g_id="";
                         knhgStore.load();
                        Ext.MessageBox.show({
                            title: '提示',
                            msg: '提交成功',
                            buttons: Ext.Msg.OK
                        });
                        //taskStore.sync();
                    }
                },
                onReturnClick:function(){
                     Ext.getCmp('mainform1').setVisible(false);
                     Ext.getCmp('tasklist1').setVisible(true);
                     window.clearInterval(timeId);
                     g_id="";
                },
                onBackClick: function() {
               // var selection = this.getView().getSelectionModel().getSelection()[0];
               var tempid=this.form._record.data.id;
                var dlg=Ext.create('Ext.window.Window', {
                                            width: 400,
                                            height: 209,
                                            closable: true,
                                            draggable: true,
                                            resizable: false,
                                            maximized:false,
                                            title:'填写退回原因',
                                            modal:true,
                                            id:'dlg1',
                                            layout: {
                                                type: 'hbox',
                                                align: 'stretch'
                                            },
                                            items: [{
                                                xtype:'backdlg',
                                                id:'backdlg1',
                                                onClickOK:function(){
                                                    Ext.Ajax.request( {
                                                    url :'workflow_back_ajax.aspx?id='+tempid+'&text='+Ext.getCmp('backArea').getValue(),
                                                    method :'post',
                                                   
                                                    success : function(d) {
                                                    Ext.getCmp('dlg1').destroy();
                                                       Ext.MessageBox.show({
                                                            title: '提示',
                                                            msg: '操作成功',
                                                            buttons: Ext.Msg.OK
                                                        });
                                                        taskStore.load({
                                                         params: {
                                                                      wfid: fl_id
                                                                 }
                                                    }); 
                                                    },
                                                    failure : function() {
                                                    Ext.getCmp('dlg1').destroy();
                        		                        Ext.MessageBox.show({
                                                            title: '提示',
                                                            msg: '操作失败',
                                                            buttons: Ext.Msg.OK
                                                        });
                                                    }
                                                });
                                                },
                                                onClickCancel:function(){
                                                    Ext.getCmp('dlg1').destroy();
                                                }
                                                
                                            }]
                                       });
                           dlg.show();
                  
                }
                
        },{
            xtype:'tasklist',
            id:'tasklist1',
            region:'north',
            width:200,
            collapsible: true,
            
            height:500,
            store:taskStore,
            onExecClick: function() {
                    var selection = this.getView().getSelectionModel().getSelection()[0];
                    //alert(selection.data.gsbm);
                      //console.log(selection.data.gsbm);
                      Ext.Ajax.request( {
                            url :'workflow_check_ajax.aspx?type=check&id='+selection.data.id,
                            method :'post',
                           
                            success : function(r,o) {
                                var respText =  r.responseText.substring(0,1); 
                              //if(respText=="0")
                             // { 
                                   changeDate(selection.data);
                                   Ext.getCmp('mainform1').setActiveRecord(selection);// || null);
                                    Ext.getCmp('mainform1').setVisible(true);
                                    Ext.getCmp('tasklist1').setVisible(false);
                                    recursionSet(Ext.getCmp('mainform1'),fl_id);
                                     Ext.getCmp('imagedataview').setDisabled(false);
                                     Ext.getCmp('imagedataview').allowBlank=false;
                                     Ext.Ajax.request( {
                                        url :'workflow_check_ajax.aspx?type=update&id='+selection.data.id,
                                        method :'post'});
                                    g_id=selection.data.id;
                                    timeId=window.setInterval("updateUsing()",25000);  
                               // }
                              /* else
                               {
                                    Ext.MessageBox.show({
                                                title: '提示',
                                                msg: '当前任务被其他用户占用，暂时不能操作。',
                                                buttons: Ext.Msg.OK
                                            });
                               }*/
                               
                            },
                            failure : function(d) {
        		                alert(d);
                            }
                        });
                   
                        },
                        onAddClick: function() {
                            Ext.getCmp('mainform1').setTitle('隐患排查治理档案表--上报隐患');
                                                                Ext.getCmp('mainform1').setVisible(true);
                                                                Ext.getCmp('tasklist1').setVisible(false);
                            recursionSet(Ext.getCmp('mainform1'),fl_id);
                            Ext.getCmp('imagedataview').setDisabled(false);
                             Ext.getCmp('imagedataview').allowBlank=false;
               
                            initStore.load({
                                params: {
                                            wfid:fl_id
                                        },
                               callback:function(){changeDate(initStore.data.items[0].data);
                           Ext.getCmp('mainform1').setActiveRecord(initStore.data.items[0]);}
                            });
                           
                   
                },
                onEditClick: function() {
                    var selection = this.getView().getSelectionModel().getSelection()[0];
                    changeDate(selection.data);
                   Ext.getCmp('mainform1').setActiveRecord(selection);// || null);
                                                        Ext.getCmp('mainform1').setVisible(true);
                                                        Ext.getCmp('tasklist1').setVisible(false);
                    recursionSet(Ext.getCmp('mainform1'),fl_id);
                    Ext.getCmp('imagedataview').setDisabled(false);
                     Ext.getCmp('imagedataview').allowBlank=false;
                },
                onChangeClick:function(){
                     var selection = this.getView().getSelectionModel().getSelection()[0];
                     var dlg=Ext.create('Ext.window.Window', {
                                            width: 306,
                                            height: 231,
                                            closable: true,
                                            draggable: true,
                                            resizable: false,
                                            maximized:false,
                                            title:'归属部门修改',
                                            modal:true,
                                            id:'dlg_changes',
                                            layout: {
                                                type: 'hbox',
                                                align: 'stretch'
                                            },
                                            items: [{
                                                xtype:'changedlg',
                                                id:'changedlg1',
                                                onClickOK:function(){
                                                    Ext.Ajax.request( {
                                                    url :'workflow_change_ajax.aspx?id='+selection.data.id+'&zy='+Ext.getCmp('change_zy').getValue()+'&gsbm='+Ext.getCmp('change_gsbm').getValue()+'&txt='+Ext.getCmp('change_txt').getValue(),
                                                    method :'post',
                                                   
                                                    success : function(d) {
                                                    Ext.getCmp('dlg_changes').destroy();
                                                       Ext.MessageBox.show({
                                                            title: '提示',
                                                            msg: '操作成功',
                                                            buttons: Ext.Msg.OK
                                                        });
                                                        taskStore.load({
                                                         params: {
                                                                      wfid: fl_id
                                                                 }
                                                    }); 
                                                    },
                                                    failure : function() {
                                                    Ext.getCmp('dlg_changes').destroy();
                        		                        Ext.MessageBox.show({
                                                            title: '提示',
                                                            msg: '操作失败',
                                                            buttons: Ext.Msg.OK
                                                        });
                                                    }
                                                });
                                                },
                                                onClickCancel:function(){
                                                    Ext.getCmp('dlg_changes').destroy();
                                                }
                                                
                                            }]
                                       });
                           Ext.getCmp('change_zy').setValue(selection.data.yhzyfl);
                           Ext.getCmp('change_gsbm').setValue(selection.data.gsbm);
                           dlg.show();
                },
                onStateClick:function(){
                    var dlg = new workflow.views.statedlg();
                    dlg.show();
                }
              
            }]
        }]
     });
   initCom(fl_id,fl_text);
});

Ext.define('workflow.views.statedlg', {
    extend: 'Ext.window.Window',
    alias:'widget.statedlg',
    height: 171,
    width: 578,
    layout: {
        type: 'anchor'
    },
    title: '隐患记录颜色说明',

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'container',
                    height: 20,
                    margin: '10 0 0 0',
                    anchor: '100%',
                    items: [
                        {
                            xtype: 'label',
                            height: 20,
                            margin: '10 0 0 5',
                            style: 'color:#FF0000',
                            width: 48,
                            text: '1)	红色字体：过期未消除记录，“是否消除”为“否”，且已超出“治理期限——至”的记录；'
                        }
                    ]
                },
                {
                    xtype: 'container',
                    height: 20,
                    anchor: '100%',
                    items: [
                        {
                            xtype: 'label',
                            margin: '10 0 0 5',
                            style: 'color:#FF9900',
                            text: '2)	黄色字体：“是否消除”为“否”，且离截止日期在7天以内（含7天）的隐患；'
                        }
                    ]
                },
                {
                    xtype: 'container',
                    height: 20,
                    anchor: '100%',
                    items: [
                        {
                            xtype: 'label',
                            margin: '10 0 0 5',
                            text: '3)	黑色代表：“是否消除”为“是”或离“治理期限——至”超过7天的记录；'
                        }
                    ]
                }
//                ,
//                {
//                    xtype: 'container',
//                    height: 30,
//                    anchor: '100%',
//                    items: [
//                        {
//                            xtype: 'label',
//                            html: '*未消除 且 为一般/重大事故隐患 且 已审核完成，图表中显示一个<img src="../admin/resources/images/error.png"></iimg>',
//                            margin: '10 0 0 5',
//                            text: '*未消除 且 为一般/重大事故隐患 且 已审核完成，图表中显示一个'
//                        }
//                    ]
//                }
            ]
        });

        me.callParent(arguments);
    }
    
});


Ext.define('workflow.views.backdlg', {
    extend: 'Ext.container.Container',
    alias:'widget.backdlg',
    height: 209,
    width: 400,
    resizable: false
,
    layout: {
        type: 'anchor'
    },

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'textareafield',
                    height: 122,
                    margin: '10 0 0 10',
                    width: 365,
                    fieldLabel: '退回原因',
                    id:'backArea',
                    labelWidth: 60
                },
                {
                    xtype: 'container',
                    height: 37,
                    layout: {
                        type: 'column'
                    },
                    items: [
                        {
                            xtype: 'button',
                            height: 27,
                            margin: '5 10 0 130',
                            width: 66,
                            text: '确定',
                            handler:this.onClickOK
                        },
                        {
                            xtype: 'button',
                            height: 27,
                            margin: '5 0 0 0',
                            width: 66,
                            text: '取消',
                            handler:this.onClickCancel
                        }
                    ]
                }
            ]
        });

        me.callParent(arguments);
    }
});

var doCollapse=function(wfid)
{
    if(wfid=='100')
    {
        
    }
};

Ext.define('workflow.views.changedlg', {
    extend: 'Ext.container.Container',
    alias:'widget.changedlg',
    height: 231,
    width: 306,
    resizable: false,

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'combobox',
                    id: 'change_zy',
                    margin: '10 0 0 10',
                    width: 262,
                    name: 'change_zy',
                    fieldLabel: '专业',
                    labelWidth: 60,
                    displayField:'text',
                    valueField:'text',
                    editable: false,
                    store:yhzyflStore,
                    listeners:{
                        select:function(com,record,obj)
                        {
                            Ext.Ajax.request( {
                                        url :'workflow_check_ajax.aspx?type=gsbm&fl='+this.getValue(),
                                        method :'post',
                                       
                                        success : function(r,o) {
                                            var txt=r.responseText;
                                            if(txt.length>2)
                                                Ext.getCmp('change_gsbm').setValue(txt.substring(0,txt.indexOf('|')));
                                        },
                                        failure : function() {
                                        
                                        }
                                    });
                        }
                    }
                },
                {
                    xtype: 'combobox',
                    id: 'change_gsbm',
                    margin: '10 0 0 10',
                    width: 262,
                    fieldLabel: '归属部门',
                    labelWidth: 60,
                     editable: false,
                    displayField:'dwName',
                    valueField:'dwName',
                    store:gsbmStore
                },
                {
                    xtype: 'textareafield',
                    margin: '10 0 0 10',
                    width: 261,
                    fieldLabel: '原因',
                    id:'change_txt',
                    labelWidth: 60
                },
                {
                    xtype: 'container',
                    height: 53,
                    items: [
                        {
                            xtype: 'button',
                            height: 26,
                            margin: '15 10 0 90',
                            width: 64,
                            text: '确定',
                            handler:this.onClickOK
                        },
                        {
                            xtype: 'button',
                            height: 26,
                            margin: '15 0 0 0',
                            width: 64,
                            text: '取消',
                            handler:this.onClickCancel
                        }
                    ]
                }
            ]
        });

        me.callParent(arguments);
    }
});
